Skip to content

Feature/projection#130

Merged
brunomendola merged 12 commits intoqueritylib:mainfrom
vage88sg1:feature/projection-safe
Dec 9, 2025
Merged

Feature/projection#130
brunomendola merged 12 commits intoqueritylib:mainfrom
vage88sg1:feature/projection-safe

Conversation

@vage88sg1
Copy link
Contributor

No description provided.

Riccardo Vagelli and others added 7 commits December 5, 2025 20:05
- Add Select interface and SimpleSelect implementation
- Add NativeSelectWrapper for native select support
- Add hasSelect() and getSelect() to Query
- Add selectBy() method to QueryBuilder (renamed from select to avoid Jackson conflict)
- Add findAllProjected() method to Querity interface with default implementation
- Implement projection support in JPA module (JpaSelect, JpaSimpleSelect, JpaQueryFactory)
- Implement projection support in MongoDB module (MongodbSelect, MongodbSimpleSelect, MongodbQueryFactory)
- Implement projection support in Elasticsearch module (ElasticsearchSelect, ElasticsearchSimpleSelect, ElasticsearchQueryFactory)
- Add SELECT keyword to parser grammar
- Add SelectUtils for native select wrapper resolution
- Add tests for select in spring-web module

Note: Using SimpleSelect (concrete class) instead of Select (interface) in Query
to avoid Jackson deserialization issues with polymorphic types.
- Add SimpleSelectTest for API module
- Add JpaSelectTests for JPA module
- Add parser tests for SELECT keyword in QuerityParserTests
- Create SelectDeserializer following the same pattern as ConditionDeserializer
- Register SelectDeserializer in QuerityModule
- Change Query.select from SimpleSelect to Select interface
- Add getPropertyNames() method to Select interface
- Update JpaSelect, MongodbSelect, ElasticsearchSelect to accept Select interface
- Update QueryVisitor to use Select interface

This approach is more consistent with how Condition is handled and allows
for proper polymorphic deserialization of Select implementations.
- Create SortDeserializer following the same pattern as ConditionDeserializer and SelectDeserializer
- Register SortDeserializer in QuerityModule
- Remove @JsonTypeInfo/@JsonSubTypes annotations from Sort interface

Now all three interfaces (Condition, Select, Sort) use custom deserializers
registered in QuerityModule for consistent and predictable JSON parsing.
- Add NativeSelectWrapperTest for API module
- Add DeserializerTests for SelectDeserializer and SortDeserializer
- Add test for unsupported Select type in JpaSelectTests
- Coverage improvements:
  - querity-api: 98%
  - querity-spring-web: 99%
  - querity-jpa-common: 78%
- Add DateValueExtractorTests for Date value extraction
- Add SelectUtilsTests for NativeSelectWrapper handling
- Add SpecificationTests for JPA Specification.where()
- Add projection tests for Elasticsearch, MongoDB, and JPA
- Add additional parser tests for edge cases
- Fix DeserializerTests assertions for exception handling
- Extend JpaSelectTests with NativeSelectWrapper tests
- Configure JaCoCo to exclude ANTLR generated classes
@brunomendola
Copy link
Member

Hi @vage88sg1 , thanks for the contribution!

Could you please add some integration tests?

Tests for selectBy would go into QuerityGenericTestSuite, and tests for selectByNative would go in the specific subclasses of QuerityGenericTestSuite.

Thanks!

@brunomendola brunomendola self-requested a review December 6, 2025 10:07
riccardovagelli and others added 2 commits December 6, 2025 22:06
- Add SelectTests to QuerityGenericTestSuite with tests for selectBy
- Add SelectionSpecification interface for native JPA selection expressions
- Add AliasedSelectionSpecification for selections with custom aliases
- Add JpaSelectionSpecificationSelectWrapper for native select support
- Add selectByNative tests with concat expression in JPA test classes
- Add sortByNative test with expression (cb.length) in JPA test classes
- Update README with documentation for projections and native expressions
- Update JpaSelect interface to include CriteriaBuilder parameter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vage88sg1
Copy link
Contributor Author

done

@brunomendola
Copy link
Member

@vage88sg1 could you please take a look at the tests that are not passing?

- givenSelectByTwoFields: relax lastName assertion (null values may be
  excluded from projections in MongoDB/Elasticsearch)
- givenSelectByNestedField: accept both flat 'city' and nested
  'address.city' structures (Elasticsearch returns nested structure)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vage88sg1
Copy link
Contributor Author

now should be ok

Copy link
Member

@brunomendola brunomendola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I've added a few comments to guide you in the structure of the project, there is some code that could be better placed, but apart from that it's a neat PR! Well done!

@brunomendola brunomendola self-assigned this Dec 8, 2025
riccardovagelli and others added 2 commits December 8, 2025 22:51
- Relocate selectByNative tests from SpringPostgresqlQuerityJpaImplTests to QuerityJpaImplTests
- Tests validate SQL database behavior generally, not Postgres-specific edge cases
- Enhance givenSelectByTwoFields test with lastName IS_NOT_NULL filter
- Restore lastName containsKey assertion for more robust validation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@brunomendola brunomendola merged commit 053c3fa into queritylib:main Dec 9, 2025
1 of 2 checks passed
@vage88sg1 vage88sg1 deleted the feature/projection-safe branch December 18, 2025 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants